package com.wangxinyuchuan.demo.builder;

/**
 * @author wangxinyuchuan
 * @date 2023/4/16 12:50 PM
 */
public class TextBuilder extends Builder{

    private StringBuffer buffer = new StringBuffer();
    @Override
    public void makeTitle(String title) {
        buffer.append("===============================\n");
        buffer.append("「").append(title).append("」\n");
        buffer.append("\n");
    }

    @Override
    public void makeString(String str) {
        buffer.append('□').append(str).append("\n");
    }

    @Override
    public void makeItems(String[] items) {
        for (int i = 0; i < items.length; i++) {
            buffer.append("~" + items[i] + "\n");
        }
        buffer.append("\n");
    }

    @Override
    public void close() {
        buffer.append("===============================\n");
    }

    public String getResult() {
        return buffer.toString();
    }
}
